/****************************************************************************/
/* NAME:           temperature.h                                            */
/* PURPOSE:        Manage all oscillator                                    */
/* CREATED_BY:     Vyx                                                      */
/* CREATION_DATE:  07/07/2012                                               */
/************************************** (C) Copyright 2012 AquaLink *********/

#include "main.h"
#include "tmp100_driver.h"
#include "fan.h"

#define _TEMP_MAX          (0x320) /* 50°C */
#define _TEMP_MIN          (0x000) /*  0°C */
#define _TEMP_RESOLUTION   ((double)0.5)
#define NB_SAMPLE_TEMP     (5)
#define NB_SENSOR_TEMP     (4)

#define TEMP_SENSOR_0      TMP100_ADDR_0
#define TEMP_SENSOR_1      TMP100_ADDR_1
#define TEMP_SENSOR_2      TMP100_ADDR_2
#define TEMP_SENSOR_3      TMP100_ADDR_3

typedef struct
{
    uint8_t           id;
    uint8_t           temp_addr;
    FAN_SETPOINT_ROLE role;
    double            setPoint;
    double            temp_value;
    bool              YearsRegulation;
}Temp_def_t;

/**
  * @brief  Main function of temperature.
  * @param  none
  * @retval None
  */
void vTaskCTRL_TEMPERATURE();

/**
  * @brief  Init function of temperature.
  * @param  none
  * @retval None
  */
void init_TEMPERATURE();

/**
  * @brief  Read temperature
  * @param  Temp to be read, address of sensor to be read
  * @retval Read status
  */
uint8_t ReadTemp(double *temp, uint8_t addr);

/**
  * @brief  Read temperature
  * @param  address of sensor to be read
  * @retval Temp read
  */
void ReadDebouncedTemp(double *temp, FAN_SETPOINT_ROLE role);

/**
  * @brief  Get set point of sensor
  * @param  address of sensor to be read
  * @retval Temp read
  */
void TEMP_GetSetpointTemp(double *setPoint, FAN_SETPOINT_ROLE role);

/**
  * @brief  Set set point of sensor
  * @param  address of sensor to be read
  * @retval Temp read
  */
void TEMP_SetSetpointTemp(double *setPoint, FAN_SETPOINT_ROLE role);


